export default {
  state() {
    return {
      isLogin: false,
      pageLoading: false
    };
  },
  mutations: {
    setLogin(state, isLogin) {
      state.isLogin = isLogin;
    },
    setPageLoading(state, pageLoading) {
      state.pageLoading = pageLoading;
    }
  },
  actions: {
    // 服务端初始化时从 Cookie 恢复状态
    nuxtServerInit({ commit }, { req }) {
      const token = this.$cookies.get('token');
      if (token) {
        commit('setLogin', true);
      }
    }
  }
};
